package fun.shuofeng.juc.test;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author 朔风
 * @date 2024-01-28 17:16
 */
public class NoSafeThreadDemo {
    public static void main(String[] args) {
        // List<String> list = new ArrayList<>();
        List<String> list = new CopyOnWriteArrayList<>();

        for (int i = 0; i < 100; i++) {
            new Thread(() -> {
                list.add(UUID.randomUUID().toString().substring(0, 4));
                System.out.println(list);
            }, "线程" + i).start();
        }

    }
}
